package com.tech.zhidengxian.service.impl;

import com.tech.zhidengxian.mapper.CategoryMapper;
import com.tech.zhidengxian.model.dataobject.CategoryDO;
import com.tech.zhidengxian.model.dto.CategoryDTO;
import com.tech.zhidengxian.service.api.CategoryService;
import com.tech.zhidengxian.util.JacksonUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class CategoryServiceImpl implements CategoryService {
    @Resource
    private CategoryMapper classifyMapper;
    @Override
    public boolean insert(CategoryDTO classifyDTO) {
        CategoryDO classifyDO = JacksonUtils.convert(classifyDTO, CategoryDO.class);
        int insert = classifyMapper.insert(classifyDO);
        return insert>0;
    }

    @Override
    public List<CategoryDTO> queryCategoryList() {
        List<CategoryDO> categoryDOS = classifyMapper.selectCategoryList();
        List<CategoryDTO> categoryDTOList = JacksonUtils.convertList(categoryDOS, CategoryDTO.class);
        return categoryDTOList;
    }
}
